<template>
	<view>

		<u-sticky offset-top="1">
			<u-tabs :lineWidth="25" :list="statuslist" @click="selectStatues">

			</u-tabs>

		</u-sticky>

		<view class="search">
			<u-search class="left" placeholder="请输入关键字" @change="selectparams" :bgColor="searchstyle"
				:borderColor="borderstyle" :showAction="false" v-model="keyword"></u-search>
			<view class="backtop">
				<u-button type="primary" @click="topback" class="custom-style" :plain="true" size="mini"
					text="返回顶部"></u-button>

			</view>

		</view>






		<!-- <u-loading-icon :show="loadshow" :duration="3000" text="加载中" /> -->

		<view v-if="empty == 'isempty'" class="list">
			<u-empty mode="list" icon="http://cdn.uviewui.com/uview/empty/list.png">

			</u-empty>
		</view>




		<u-cell-group v-if="empty == 'notempty'">

			<u-swipe-action>

				<view class="Box">
					<u-list :height="580" :preLoadScreen="page * 5" @scrolltolower="scrolltolower">


						<u-list-item v-for="item in list" :key="item.id">
	
							<u-swipe-action-item class="box" :disabled="true" :options="options"
								:name="item.id">
								<view class="card_img">
									<u--image :showLoading="true" :src="item.avatar" :lazy-load="true"
										width="80px" height="80px"></u--image>
	
								</view>
								<u-cell @click="info({supid:item.id})" :label="'  申请人 : ' +
									item.nickname +
									'  申请时间 :' +
									item.createtime_text +
									'  审批单号: ' + 
									item.code +  
									'预想店铺名称: ' +
									item.storename 
									" :key="item.id" center>
									<view slot="title" class="u-slot-title">
										<span class="tag">
											<u-tag v-if="item.status == '1'" :text="item.status_text" plain="true" size="mini"
												type="primary" />
										</span>
	
										<span class="tag">
											<u-tag v-if="item.status == '2'" :text="item.status_text" plain="true" size="mini"
												type="success" />
										</span>
										<span class="tag">
											<u-tag v-if="item.status == '3'" :text="item.status_text" plain="true" size="mini"
												type="error" />
										</span>
									
	
										
	
	
									</view>
								</u-cell>
	
							</u-swipe-action-item>
							
						</u-list-item>
	
						<u-loadmore :status="flag" :loading-text="loadingText" :loadmore-text="loadmoreText"
							:nomore-text="nomoreText" />
	
					</u-list>
				</view>
			</u-swipe-action>

		</u-cell-group>





		<!-- 消息提醒 -->
		<u-toast ref="notice"></u-toast>

	</view>
</template>

<script>

export default {
	onLoad() {
		this.auth = this.$u.auth.check()
		this.shenpiindex()
		this.statulist()


	},
	onShow() {
		const currentDate = new Date();
		const currentYear = currentDate.getFullYear();

		const nextdate = currentYear + 1;
		const lastdate = currentYear - 1;
		// 前年时间段
		this.lastYeardate = lastdate + "-" + "01" + "-" + "1"
		// 明年时间段
		this.nextYeardate = nextdate + "-" + "12" + "-" + "31"


	},

	created() {
		this.timer = setInterval(() => {

			this.$u.count.check()
			this.statulist()

		}, 15000);

	},
	beforeDestroy() {
		clearInterval(this.timer)
	},
	data() {
		return {
			filtershow: false,
			columns: [

			],
			columnData:[],

			count: {},
			showdate: false,
			qx: "",
			mode: 'range',
			timelist: {},
			flag: 'loading',
			loadingText: '努力加载中',
			loadmoreText: '下拉加载更多',
			nomoreText: '没有更多数据了',
			statuslist: [],
			type: "",
			options: [{
				text: "",
				style: {
					backgroundColor: "#3c9cff",
				},
			},],
			status: 0,
			src: 'https://cdn.uviewui.com/uview/album/1.jpg',
			btn: {
				width: "125px",
				height: "45px",
			},
			reset: {
				width: "100px",
				height: "35px",
				color: "#736b6b"


			},
			submit: {
				width: "100px",
				height: "35px",
			},
			listprops: {
				height: "265px"
			},
			tcshow: false,
			keyword: "",
			show: false,
			auth: {},
			list: [],
			typeName: "",
			xzstoid: "",
			storeName: "",
			page: 1,
			supid: 0,
			searchstyle: "#ffffff",
			borderstyle: "#eee",
			empty: "",
			total1: 0,
			total2: 0,
			date: "",
			lastYeardate: "",
			nextYeardate: "",
			btnStyle: {
				width: "52px",
				margin: "5% 80%",
				height: "25px",
			},



		};
	},
	methods: {

	

		async Filter(item) {


			let data = {
				adminid: this.auth.id,
				soure: item === undefined ? this.type : item.type,
				xzstoid: item === undefined ? this.xzstoid : item.stoid,
				storeName: item === undefined ? this.storeName : item.storeName,
				typeName: item === undefined ? this.typeName : item.typeName,
				keyword: this.keyword,

			}
			let result = await this.$u.api.depot.filterdata(data)
			if (result.code) {
				if (result.data.length > 0) {

					this.empty = "notempty"

					this.list = result.data

					setTimeout(function () {
						uni.hideLoading();
					}, 1200);

				} else {
					setTimeout(function () {
						uni.hideLoading();
					}, 1200);
					this.empty = "isempty"
				}
			}

		},

		selectparams(e) {
			this.page = 1

			// 直接赋值
			this.keyword = e
			// 然后调用
			uni.showLoading({
				title: '正在查询...'
			});
			this.Filter()
		},

	

		async selectStatues(e) {

			this.keyword = ""
			this.page = 1


			this.list = []
			this.flag = "loadmore"
			this.loadmoreText = ""


			// 请求数据就把数据加载的打开
			this.qx = ""


			this.status = e.status;

			let data = {
				status: e.status,
				adminid: this.auth.id,
				stoid: this.auth.stoid,
				page: 1
			}


			let result = await this.$u.api.depot.ShenpiIndex(data)

			if (result.code) {

				if (Array.isArray(result.data) && result.data.length > 0) {
					this.empty = "notempty"
					// 有数据返回就把数据加载的关闭

					this.list = result.data

				} else {


					// this.flag = "nomore"
					this.empty = "isempty"


					this.qx = ""

				}
			}

		},
		action(item) {

			this.show = true

			if (item.index == 0) {

				this.supid = item.name


			}

		},

		scrolltolower() {



			this.shenpiindex()



		},
		async spreject() {

			this.show = false;
			let data = {
				status: 2,
				adminid: this.auth.id,
				supid: this.supid
			}

			let result = await this.$u.api.depot.reject(data)

			if (result.code) {
				this.$refs.notice.show({
					type: "success",
					message: result.msg,
					duration: 2000,

				})
				setTimeout(() => {
					this.shenpiindex(this.status)
				}, 4000)

				this.$u.route(
					"/pagesC/shenpi/index", {
					supid: this.supid
				}
				)
			} else {
				this.$refs.notice.show({
					type: "error",
					message: result.msg,
					duration: 2000
				})
			}
		},
		async statulist() {
			let result = await this.$u.api.depot.shenpiStatus({ adminid: this.auth.id, stoid: this.auth.stoid })
			if (result.code) {
				this.statuslist = result.data
			}
		},
		async shenpiindex(e) {

			if (e) {

				this.status = e.status

				this.page = e.page
			}


			let data = {

				stoid: this.auth.stoid,
				adminid: this.auth.id,
				status: this.status,
				page: this.page,

			};




			let result = await this.$u.api.depot.ShenpiIndex(data);

			if (result.code) {

				if (Array.isArray(result.data) && result.data.length > 0) {


					this.empty = "notempty"

					this.list = this.list.concat(result.data);
					this.page++

				} else {
					this.flag = "nomore"
					


				}
			}else
			{
				this.empty = "isempty"

			}
		},




		info(e) {
			console.log(e)
			//订单详情
			this.$u.route(
				"/pagesC/shenpi/info", {
				supid: e.supid,
				busid:e.busid
			}
			)


		},


	},
};
</script>

<style lang="scss">
.card_img {
	position: absolute;
	left: 20px;
	top: 25px;
}

.box {
	display: flex;
	margin-top: 15px;
	justify-content: space-around;
}

.backtop {
	width: 20px;
	color: "blue";
	margin-left: 15px;
}


.content {}

.list-cell {
	display: flex;
	box-sizing: border-box;
	width: 100%;
	padding: 20px 24px;
	color: #323233;
	font-size: 14px;
	line-height: 24px;
	background-color: #fff;
}



.u-cell__label {
	width: 260px;
}



.tag {
	width: 48px;
	left: 300px;
	top: 65px;
	position: absolute;
	white-space: nowrap; /* 让文本不换行 */
	overflow: hidden; /* 隐藏溢出的文本 */
	text-overflow: ellipsis; /* 显示省略号 */


}


.tagprimary {
	width: 48px;
	left: 300px;
	top: 65px;
	
	position: absolute;

}

.Box{
	margin-top: 35px;
	
	height: 580px;
	overflow: hidden
}
.tagerror {

	width: 58px;
	top: 65px;
	left: 300px;
	position: absolute;
	white-space: nowrap; /* 让文本不换行 */
	overflow: hidden; /* 隐藏溢出的文本 */
	text-overflow: ellipsis; /* 显示省略号 */
}

.u-cell-group {
	margin-top: 70px;
	height: 670px;
	overflow: hidden;
}

.datebtn {
	width: 60px;
}

.storebtn {
	width: 60px;
}

.taginfo {
	width: 58px;
	top: 82px;
	left: 300px;
	position: absolute;
	white-space: nowrap; /* 让文本不换行 */
	overflow: hidden; /* 隐藏溢出的文本 */
	text-overflow: ellipsis; /* 显示省略号 */

}

.btngroup {
	width: 100%;
	display: flex;
	position: fixed;
	left: 0px;
	top: 100px;
	justify-content: space-around;
}

.u-cell__title {
	padding: 10px 110px;
	width: 285px;
	position: relative;

}

.tagwarning {
	width: 48px;
	left: 300px;
	left: 180px;

	position: absolute;

}

.u-cell__body__content {
	padding-bottom: 25px;
}

.recordBox {
	height: 100%;
	padding: 0 40rpx;

	.recordItem {
		margin-top: 20rpx;
		background-color: #ffffff;

		.title {
			height: 66rpx;
			padding: 0 20rpx;
			line-height: 66rpx;
			background: #e1e1e1;
			font-size: 32rpx;
			color: #141414;
			text-align: center;
		}

		.contentList {
			display: flex;
			flex-direction: column;
			font-size: 28rpx;
			color: #6d6d6d;

			.contentItem {
				display: flex;
				align-items: center;
				justify-content: space-between;
				border-bottom: 1px dashed #c1c1c1;
				height: 66rpx;
				padding: 0 20rpx;
				line-height: 66rpx;
			}
		}

		.showDetail {
			color: #548afb;
			padding: 20rpx 0;
			display: flex;
			align-items: center;
			justify-content: space-around;
		}

	}
}


.search {
	width: 80%;
	position: fixed;
	top: 7%;
	display: flex;
	justify-content: space-between;
	align-items: center;
	left: 7%;
	z-index: 999;

}
</style>
